package com.zjhd.sealcutting.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * TODO Ip工具类
 * @author wangchao
 * @date 2020/12/11 10:22
 * @param
 * @return
 */
public class IPUtil {


     /*
      * TODO  获取IP
      * @author wangchao
      * @date 2020/9/1 10:36
      * @param
      * @return
      */
    public static String getIpAddress(HttpServletRequest request){

        String ip = request.getHeader("x-forwarded-for");

        if(ip == null || ip.length() ==0 || "nuknown".equalsIgnoreCase(ip)){

            ip = request.getHeader("Proxy-Client-IP");
        }
        if(ip == null || ip.length() ==0 || "nuknown".equalsIgnoreCase(ip)){

            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if(ip == null || ip.length() ==0 || "nuknown".equalsIgnoreCase(ip)){

            ip = request.getRemoteAddr();
        }
        return ip;
    }
}
